#ifndef AutoHideTabH
#define AutoHideTabH
/*******************************************************************************
** Qt Advanced Docking System
** Copyright (C) 2017 Uwe Kindler
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/


//============================================================================
/// \file   AutoHideTab.h
/// \author Syarif Fakhri
/// \date   05.09.2022
/// \brief  Declaration of CAutoHideTab class
//============================================================================

//============================================================================
//                                   INCLUDES
//============================================================================
#include "PushButton.h"

#include "ads_globals.h"

namespace ads
{
struct AutoHideTabPrivate;
class CDockWidget;
class CAutoHideSideBar;
class CDockWidgetTab;
class DockContainerWidgetPrivate;

/**
 * 自动隐藏的侧边栏中显示的停靠窗口侧边选项卡，可以显示标题或图标。
 * 停靠窗口选项卡显示在侧边栏中，用于在固定的停靠窗口之间切换。
 */
class ADS_EXPORT CAutoHideTab : public CPushButton
{
    Q_OBJECT
    Q_PROPERTY(int sideBarLocation READ sideBarLocation)
    Q_PROPERTY(Qt::Orientation orientation READ orientation)
    Q_PROPERTY(bool activeTab READ isActiveTab)
    Q_PROPERTY(bool iconOnly READ iconOnly)

private:
    AutoHideTabPrivate* d; ///< 私有数据 (pimpl)
    friend struct AutoHideTabPrivate;
    friend class CDockWidget;
    friend class CAutoHideDockContainer;
    friend class CAutoHideSideBar;
    friend class CDockAreaWidget;
    friend class CDockContainerWidget;
    friend DockContainerWidgetPrivate;

private Q_SLOTS:
    void onAutoHideToActionClicked();

protected:
    void setSideBar(CAutoHideSideBar *SideTabBar);
    void removeFromSideBar();
    virtual bool event(QEvent* event) override;
    virtual void contextMenuEvent(QContextMenuEvent* ev) override;
    virtual void mousePressEvent(QMouseEvent* ev) override;
    virtual void mouseReleaseEvent(QMouseEvent* ev) override;
    virtual void mouseMoveEvent(QMouseEvent* ev) override;

public:
    using Super = CPushButton;

    /**
     * 默认构造函数
     * @param[in] parent 此侧边选项卡的父窗口部件
     */
    CAutoHideTab(QWidget* parent = nullptr);

    /**
     * 虚析构函数
     */
    virtual ~CAutoHideTab();

    /**
     * 如果有属性更改，则更新样式表样式
     */
    void updateStyle();

    /**
     * 获取侧边栏区域属性
     */
    SideBarLocation sideBarLocation() const;

    /**
     * 设置垂直或水平方向
     */
    void setOrientation(Qt::Orientation Orientation);

    /**
     * 返回当前方向
     */
    Qt::Orientation orientation() const;

    /**
     * 如果此选项卡是活动选项卡，则返回true。
     * 当自动隐藏窗口可见时，该选项卡为活动选项卡。
     */
    bool isActiveTab() const;

    /**
     * 返回此选项卡所属的停靠窗口
     */
    CDockWidget* dockWidget() const;

    /**
     * 设置由此选项卡控制的停靠窗口
     */
    void setDockWidget(CDockWidget* DockWidget);

    /**
     * 如果自动隐藏配置标志AutoHideSideBarsIconOnly已设置，并且选项卡具有图标（即图标不为空），则返回true。
     */
    bool iconOnly() const;

    /**
     * 返回包含此选项卡的侧边栏，如果选项卡不在侧边栏中，则返回nullptr。
     */
    CAutoHideSideBar* sideBar() const;

    /**
     * 返回此选项卡在侧边栏中的索引
     */
    int tabIndex() const;

public Q_SLOTS:
    /**
     * 如果停靠窗口可浮动，则将其设置为浮动状态
     */
    void setDockWidgetFloating();

    /**
     * 取消固定并将自动隐藏窗口停靠
     */
    void unpinDockWidget();

    /**
     * 调用分配的停靠窗口的requestCloseDockWidget()函数
     */
    void requestCloseDockWidget();
}; // class AutoHideTab
}
 // namespace ads
//-----------------------------------------------------------------------------

#endif
